﻿using BacklogParser.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Linq;

namespace BacklogParser.Parsers
{
    public static class TermOfGrantParser
    {
        public static List<LapsedInCountry> Parse(List<XElement> parties)
        {
            var result = new List<LapsedInCountry>();
            var list = parties.Descendants(Constants.Epo + "lapsed-in-country").ToList();

            foreach (var item in list)
            {
                LapsedInCountry parsed = new LapsedInCountry
                {
                    Country = item.Descendants(Constants.Epo + "country").First().Value,
                    Date = item.Descendants(Constants.Epo + "date").First().Value
                };

                result.Add(parsed);
            }
            return result;
        }
    }
}
